const clearner = (param) => {
	const obj = {}
	if (!param) return {}
	Object.entries(param)
		.filter(([, v]) => v !== undefined && v !== null)
		.forEach(([k, v]) => obj[k] = v)
	return obj
}

const searchParams = (searchStr) => {
	if (!searchStr) return {}
	const s = searchStr.substring(1)
	const pa = s.split("&")
	if (!pa) return {}
	const param = {}
	pa.forEach(s => {
		const pair = s.split('=')
		if (pair) {
			if (pair.length === 1) {
				param[pair[0]] = null
			}
			if (pair.length === 2) {
				param[pair[0]] = pair[1]
			}
		}
	})
	return param
}

export {clearner,searchParams}